package com.bawei.goods.hospital_goods.controller;

import java.util.Arrays;
import java.util.Map;

import com.bawei.common.utils.PageUtils;
import com.bawei.common.utils.R;
import com.bawei.goods.hospital_goods.vo.OrderModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import com.bawei.goods.hospital_goods.entity.OrderListEntity;
import com.bawei.goods.hospital_goods.service.OrderListService;




/**
 * 
 *
 * @author doujunxian
 * @email 602137101@gmail.com
 * @date 2021-12-09 18:45:26
 */
@RestController
@RequestMapping("hospital_goods/orderlist")
public class OrderListController {
    @Autowired
    private OrderListService orderListService;

    //审核
    @PostMapping("/uditset")
    public R uditset(@RequestBody OrderModel orderList) {
        orderListService.uditset(orderList);

        return R.ok();
    }

    //发货
    @PostMapping("/set")
    public R set(@RequestBody OrderModel orderList) {
        orderListService.set(orderList);

        return R.ok();
    }



    //获取审核信息
    @GetMapping("getaudit/{id}")
    public R getaudit(@PathVariable("id") Long id){
        OrderModel orderList = orderListService.getaudit(id);

        return R.ok().put("order", orderList);
    }

    //获取订单信息
    @GetMapping("getone/{id}")
    public R get(@PathVariable("id") Long id){
        OrderModel orderList = orderListService.getOrder(id);
        System.out.println(orderList);
        return R.ok().put("order", orderList);
    }

    /**
     * 列表
     */
        @PostMapping("/list")
        public R list(@RequestParam Map<String, Object> params){
        PageUtils page = orderListService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
         @GetMapping("/info/{id}")
        public R info(@PathVariable("id") Long id){
		OrderListEntity orderList = orderListService.getById(id);

        return R.ok().put("orderList", orderList);
        }

    /**
     * 保存
     */
    @PostMapping("/save")
        public R save(@RequestBody OrderListEntity orderList){
		orderListService.save(orderList);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
        public R update(@RequestBody OrderListEntity orderList){
		orderListService.updateById(orderList);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
        public R delete(@RequestBody Long[] ids){
		orderListService.removeByIds(Arrays.asList(ids));

        return R.ok();
    }

}
